package com.hpsk.shopservice.listener;

import com.hpsk.shopservice.model.config.controller.TestController;
import com.hpsk.shopservice.model.config.event.TestApplicationEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class TestApplicationListener implements ApplicationListener<TestApplicationEvent> {

    @Override
    public void onApplicationEvent(TestApplicationEvent event) {
        Object object = event.getObject();
        log.info("TestApplicationListener:{}", object);

        log.info("TestApplicationListener:{}", event.getSource());
        Object source = event.getSource();
        if (source instanceof TestController) {
            System.out.println("yes");
        }else {
            System.out.println("no");
        }
    }

    @Override
    public boolean supportsAsyncExecution() {
        return ApplicationListener.super.supportsAsyncExecution();
    }
}
